#!/usr/bin/env sh

# see error
set -e

RES="\033[0m" ;BLUE="\033[36m"
info_msg(){ echo -e "${BLUE}info_msg: $1 ${RES}";}

# record now time
now_time=`date` 
commit_msg=""
if [[ -n $1 ]];then
    commit_msg=$1
else
    commit_msg="update at ${now_time}"
fi
info_msg "commit_msg is: \"${commit_msg}\""

# save msg
git config --local credential.helper store

# update git
info_msg "git add、commit、pull and push"
git add .
git commit -m "${commit_msg}"
git pull
git push 